-
Notifications
You must be signed in to change notification settings - Fork 1k
Hid/DFU boot loader (superseded by #525) #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Had to build new binaries from of the HID bootloader to set the correct GPIO for BOOT1 to fix the boot into sketch issue, as it stood the source code was using a pin that would be floating. Here's what I used for Black407Vet6 (/inc/main.h):
And for Black407ZET6
ZET6 now tested and working. Will test DIYMROE next. |
You probably want to adjust the total available flash:
might be:
goes for all .ld scripts |
@RickKimball yeah very good call, will update. |
I've made the linker changes for all but BLACK407XX, the MAX size is passed in as a preprocessor variable - been at the gym so my brain is struggling to think how to knock 16KB off a preprocessed variable, or set it in boards.txt only for HID method? |
Tips: you can define new switch and use it in ld script. Ex: LD_SIZE_OFFSET |
Think I found a simpler way: FLASH (rx) : ORIGIN = 0x8004000, LENGTH = LD_MAX_SIZE - 0x4000 Seems to work - ie doesn't throw linker error |
I've left out the change to the upload method for now since 1) it works as is (no idea why) 2) it doesn't work when the correct naming is used. |
I've attached precompiled bootloader bins, labelled with the boards they match. |
What's the advantage of using this bootloader vs using the DFU versions? Thanks in advance, E. |
something more? |
Pretty much that. |
I'll upload a different formware for zet6 later, BOOT1 is pulled down on that board and it needs to be pulled up for this BL (so as an alternate it can be compiled to use PD4 which is an SDIO pin with a pullup... won't be active when the BL is running). |
maybe just try to read K0 or K1 |
After seeing the above ref, I started to play with adding maple DFU support. I can successfully upload to a maple mini with the original 0x5000 dfu bootloader - linking works well. BUT, CDC does not function - not sure why. Will test against Bluepill & Blackpill |
@BennehBoy on Maple do not forget the DISC pin PB9 handling. I will add the DISC pin management based on what is done in Roger's core. |
@fpistm of course... I had a quick look through the code but the LL stuff is beyond me at present... Here's what STM32GENERIC does:
reenumerate gets called when CDC begins. I tried 'frigging' it by issuing the same code in sketch startup, but CDC has already started at that point and things don'tr go well. On a side note, Bluepill seems to get the BL 2.0 overwritten even though the linker & vector offset are 0x2000 |
OK, fixed bluepill... So have working DFU BL 2.0 for BP 😃 Just need the DISC pin handling to get Maple Mini working |
I still can't figure out why anything other than bmpMethod fails for the naming in boards.txt |
I've pushed the DFU changes - Bluepill functional, Maple Mini semi functional but needs the USB_DISC_PIN change. |
I think the DISC_PIN handling needs inserting here -> https://github.com/stm32duino/Arduino_Core_STM32/blob/master/cores/arduino/stm32/usb/usbd_conf.c#L58 I'm struggling a bit on the LL code to initialise and toggle the pin though. |
Here's what I came up with, I used HAL... It works, but may not be the best way. This inserted just before the line indicated above. It's hard coded for PB9 at present - but tbh I think there's only Maple Mini that uses this.
|
Works a charm with #410 |
I will provide a PR tomorrow based on #410 with USB DISC PIN management and reenumerate |
just in case, please add #undefine for HiGH and LOW before #endif |
I removed those anyway - was a leftover from before conversion to HAL. |
hi no worries, i think cubeprogrammer, DFU, HID can co-exist in a sense it is kind of a variant where the start of flash and vtab address is different that's all. in terms of tools, i'd think it's alright for ST to make a decision. users can always use 'external' tools like dfu-util or hid-flash to install the sketch say on the command line separately. or some instructions in a wiki can be placed to show how to add the tools. so non issues :) |
Hi, In case the user reaches this repository (usage instructions): |
@fpistm I noticed the 1.6.0 milestone, does this mean you're refactoring with stmcubeprogrammer? |
I was wondering how long you would take to ask 😄 |
🤣 |
what about hid bootloader/programmer? it is not supported by stmcubeprogrammer. |
I will add it |
@BennehBoy, @Serasidis |
Bluepill's & Maple Mini's come preloaded with Maple DFU BL 2.0 & Maple
Original BL respectively, there's no SWD on the Maple Mini, and BL2
disables SWD on the Bluepill. This means that by not including support for
these bootloaders we would effectively orphan a lot of potential new users.
…On Thu, May 16, 2019 at 7:41 AM Frederic Pillon ***@***.***> wrote:
@BennehBoy <https://github.com/BennehBoy>, @Serasidis
<https://github.com/Serasidis>
I'm wondering if we should not keep only HID bootloader?
Is Maple DFU Bootloader 2.0 and Maple DFU Bootloader original (0x5000)
really needed?
What is your thought about that?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#415?email_source=notifications&email_token=AF6R4XQJUGPQ7DKS573DX6LPVT63LA5CNFSM4GRKECB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVQ2NCQ#issuecomment-492938890>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF6R4XUBWKBWHCSK3EMVX4DPVT63LANCNFSM4GRKECBQ>
.
|
Right, forgot this use case. |
I'm little bit lost with that. I know some users works on this but I think it was not the case here as it is not compatible with EEPROM emulation. |
Can you explain further? When I was creating the PR the HID BL author updated his repo so that the tools would refuse to flash devices with an earlier version of the BL installed.... Then some more commits were made to move the F1 version of the BL to the end of flash, these were then backed out. I've noticed some recent commits but have not had my eye close enough on it to see if the end of flash has been re-introduced (I doubt it would be due to some other issues). |
Ok so your limitation on your OP is not correct. |
The limitation is correct with the hid tool that I supplied in the tools repo. Where the loader is flashed in flash memory is irrelevant, the tool still requires v 2+ to be on the device. |
Oh ok. Sorry, i've read that it was flash on the latest sector 🤣 |
Out of curiosity, could one of you please explain what is currently hindering this PR from being merged in relatively lay-person parlance? From what this looks to be, It would be of great use to me to have this feature in the STM32duino core. |
@neilbalch |
This PR enables the use of the STM32 HID Bootloader 3.0 for Generic F103 & Generic F4 variants
Tested on Bluepill, Blackpill (using BP menu option), & Black407VET6.
Limitations:
Usage:
First apply this PR to your STM32 tools -> stm32duino/Arduino_Tools#33.
HID:
Select your variant in the boards menu
Set the upload method to "HID Bootloader 3.0 (0x0800)" for F1 or "HID Bootloader 3.0 (0x4000)" for F4
Ensure that "USB Interface (if available):" is set to "CDC Full Speed" (required for DTR toggling)
DFU:
The PR applies the magic word & byte code recognition to USB_CDC_IF.cpp which also enables STM32Duino Bootloader 2.0 to work.
Also included is DISC pin handling for Maple Mini. This is the same logic used in Roger Clarke's core and in STM32GENERICSelect your variant in the boards menu
Set the upload method to "Maple DFU Bootloader 2.0" or "Maple DFU Bootloader original (0x5000)" depedning on the BL installed.
Ensure that "USB support (if available):" is set to either CDC option (required for DTR toggling)
Note - edited due to changes to HID Bootloader 3.0 on 21/1/19. & addition of DFU 27/1/2019